$(function () {
    //表单验证
    $.formValidator.initConfig({
        formID: "dataForm", mode: 'AutoTip', onError: function (msg) {
            alert(msg)
        }
    });
    $("#store_name").formValidator({onShow: "", onFocus: "请输入店铺名称"}).inputValidator({
        min: 6,
        max: 60,
        onError: "店铺名称不合格"
    });
    $("#manager_name").formValidator({onShow: "", onFocus: "请输入店长名字"}).inputValidator({
        min: 2,
        max: 10,
        onError: "店长名字不合格"
    });
    $("#headimg").formValidator({onShow: "", onFocus: "请上传店铺头像"}).inputValidator({min: 1, onError: "店铺头像不能为空"});
    $("#mobile").formValidator({onShow: "", onFocus: "请输入登录手机号"}).inputValidator({
        min: 10,
        max: 12,
        onError: "登录手机号格式错误"
    });
    $("#password").formValidator({onShow: "", onFocus: "请输入登录密码"}).inputValidator({
        min: 6,
        max: 18,
        onError: "登录密码格式错误"
    });
    $("#province1").formValidator({onShow: "", onFocus: "请选择所在省份"}).inputValidator({
        min: 1,
        onError: "所在省份不能为空"
    });
    $("#city1").formValidator({onShow: "", onFocus: "请选择所在城市"}).inputValidator({
        min: 1,
        onError: "所在城市不能为空"
    });
    $("#area1").formValidator({onShow: "", onFocus: "请选择所在地区"}).inputValidator({
        min: 1,
        onError: "所在地区不能为空"
    });
    $("#suggestId").formValidator({onShow: "", onFocus: "请输入详细地址"}).inputValidator({
        min: 1,
        max: 255,
        onError: "详细地址格式错误"
    });
    $("#longitude").formValidator({onShow: "", onFocus: "请选择经度"}).inputValidator({
        min: 1,
        onError: "经度不能为空"
    });
    $("#latitude").formValidator({onShow: "", onFocus: "请选择纬度"}).inputValidator({
        min: 1,
        onError: "纬度不能为空"
    });
    $('input[type=checkbox]').formValidator({
        onShow: "",
        onFocus: "（至少选择一个）",
        onCorrect: "（正确）"
    }).functionValidator({
        fun: function (val, elem) {
            var objs = $('input[type=checkbox]');
            for (var i = 0; i < objs.length; i++) {
                console.log($(objs[i]).attr("checked"));
                if ($(objs[i]).attr("checked") == 'checked') {
                    return true;
                }
            }

            return '至少选择一项';
        }
    });
});